package com.ruoyi.web.controller.project;

import java.util.List;

import com.ruoyi.common.config.Global;
import com.ruoyi.framework.util.FileUploadUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.Xyzlb;
import com.ruoyi.project.service.IXyzlbService;
import com.ruoyi.web.core.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import org.springframework.web.multipart.MultipartFile;

/**
 * 学员资料 信息操作处理
 *
 * @author ruoyi
 * @date 2018-11-01
 */
@Controller
@RequestMapping("/project/xyzlb")
public class XyzlbController extends BaseController {
    private String prefix = "project/xyzlb";

    @Autowired
    private IXyzlbService xyzlbService;

    @RequiresPermissions("project:xyzlb:view")
    @GetMapping()
    public String xyzlb () {
        return prefix + "/xyzlb";
    }

    //弹出框显示的学员信息
    @RequiresPermissions("project:xyzlb:view")
    @GetMapping("/data")
    public String xyzlbData () {
        return prefix + "/xyzlb_data";
    }

    /**
     * 查询学员资料列表
     */
    @RequiresPermissions("project:xyzlb:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list (Xyzlb xyzlb) {
        startPage();
        List<Xyzlb> list = xyzlbService.selectXyzlbList(xyzlb);
        return getDataTable(list);
    }

    /**
     * 新增学员资料
     */
    @GetMapping("/add")
    public String add () {
        return prefix + "/add";
    }

    /**
     * 新增保存学员资料
     */
    @RequiresPermissions("project:xyzlb:add")
    @Log(title = "学员资料", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave (Xyzlb xyzlb) {
            return toAjax(xyzlbService.insertXyzlb(xyzlb));
    }

    /**
     * 修改学员资料
     */
    @GetMapping("/edit/{xyzlbId}")
    public String edit (@PathVariable("xyzlbId") Integer xyzlbId, ModelMap mmap) {
        Xyzlb xyzlb = xyzlbService.selectXyzlbById(xyzlbId);
        mmap.put("xyzlb", xyzlb);
        return prefix + "/edit";
    }


    /**
     * 修改保存学员资料
     */
    @RequiresPermissions("project:xyzlb:edit")
    @Log(title = "学员资料", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave (Xyzlb xyzlb) {
            return toAjax(xyzlbService.updateXyzlb(xyzlb));
    }

    /**
     * 删除学员资料
     */
    @RequiresPermissions("project:xyzlb:remove")
    @Log(title = "学员资料", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove (String ids) {
        return toAjax(xyzlbService.deleteXyzlbByIds(ids));
    }

}
